# 导包
'''import unittest
from api.login import LoginAPI
from common.common_assert import common_assert
# 创建测试类
class TestLoginAPI(unittest.TestCase):
    # 登录成功
    def test01_success(self):
        response = LoginAPI().login({"mobile": "13800000002", "password": "123456"})
        print(response.json())
        # 断言
        # self.assertEqual(200, response.status_code)
        # self.assertEqual(True, response.json().get("success"))
        # self.assertEqual(10000, response.json().get("code"))
        # self.assertIn("成功", response.json().get("message"))
        # self.assertIn("成功", response.text)
        common_assert(self, response, 200, True, 10000, "成功")
    # 账号错误
    def test02_mobile_error(self):
        response = LoginAPI().login({"mobile": "13866778899", "password": "123456"})
        print(response.json())
        # 断言
        # self.assertEqual(200, response.status_code)
        # self.assertEqual(False, response.json().get("success"))
        # self.assertEqual(20001, response.json().get("code"))
        # self.assertIn("错误", response.json().get("message"))
        # self.assertIn("错误", response.text)
        common_assert(self, response, 200, False, 20001, "错误")
    # 密码错误
    def test03_password_error(self):
        response = LoginAPI().login({"mobile": "13800000002", "password": "123457"})
        print(response.json())
        # 断言
        # self.assertEqual(200, response.status_code)
        # self.assertEqual(False, response.json().get("success"))
        # self.assertEqual(20001, response.json().get("code"))
        # self.assertIn("错误", response.json().get("message"))
        # self.assertIn("错误", response.text)
        common_assert(self, response, 200, False, 20001, "错误")'''
import unittest
from api.login import LoginAPI

import requests

import config
from common.common_assert import common_assert
# def common_assert(case,response,status_code,success,code,message):
#     case.assertEqual(status_code, response.status_code)

class TestLoginAPI(unittest.TestCase):
    def test01_sucess(self):
        response=LoginAPI().login({"mobile": "13800000002", "password": "123456"})
        common_assert(self, response, 200, True, 10000, "成功")
    def test02_mobile_error(self):
        response=LoginAPI().login({"mobile": "13800000000", "password": "123456"})
        common_assert(self, response, 200, False, 20001, "错误")
    def test03_password_error(self):
        response=LoginAPI().login({"mobile": "13800000000", "password": "123457"})
        # self.assertEqual(200,response.status_code)
        # self.assertEqual(False,response.json().get("success"))
        # self.assertEqual(20001, response.json().get("code"))
        # self.assertIn("错误",response.json().get("message"))
        common_assert(self, response, 200, False, 20001, "错误")


